package mbms.mobilebudget.creditCard;

import java.util.List;

import mbms.mobilebudget.R;
import mbms.mobilebudget.entity.CreditCard;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.TextView;

public class CreditCardAdapter extends ArrayAdapter<CreditCard> {

    private List<CreditCard> items;

    public CreditCardAdapter(Context context, int textViewResourceId, List<CreditCard> items) {
            super(context, textViewResourceId, items);
            this.items = items;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        View v = convertView;
        if (v == null) {
            LayoutInflater vi = (LayoutInflater)getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
            v = vi.inflate(R.layout.credit_card_row, null);
        }
        
        CreditCard creditCard = items.get(position);
        if (creditCard != null) {
                TextView tt = (TextView) v.findViewById(R.id.toptext);
                TextView bt = (TextView) v.findViewById(R.id.bottomtext);
                if (tt != null) {
                      tt.setText("Name: "+creditCard.getBankName());                            }
                if(bt != null){
                      bt.setText("Curreny Type: "+ creditCard.getCurrencyType().name());
                }
        }
        
        return v;
    }
}
